/**
 * @author hewei
 * @version 1.0
 * @description: 1109. 航班预订统计
 * @date 2022/10/29 16:18
 */

public class CorpFlightBookings {

    public int[] corpFlightBookings(int[][] bookings, int n) {
        int[] count = new int[20002];
        for (int[] booking : bookings) {
            count[booking[0]] += booking[2];
            count[booking[1] + 1] -= booking[2];
        }
        int[] ans = new int[n];
        int temp = 0;
        for (int i = 0; i < n; i++) {
            temp += count[i + 1];
            ans[i] = temp;
        }
        return ans;
    }
}
